
/*
 * Change Logs:
 * Date           Author       Notes
 * 2022-01-27     tyustli          first implementation
 */

#ifndef __SEQUENCE_H__
#define __SEQUENCE_H__
#include "def.h"

#define LIST_INIT_SIZE 10 // 线性表存储空间的初始分配量
#define LIST_INCREMENT 2  // 线性表存储空间的分配增量
typedef int ElemType;

struct SqList
{
    ElemType *elem; // 存储空间基址
    int length;     // 当前长度
    int listsize;   // 当前分配的存储容量(以sizeof(ElemType)为单位)
};

void InitList(struct SqList *L);
void DestroyList(struct SqList *L);
void ClearList(struct SqList *L);
Status ListEmpty(struct SqList L);
int ListLength(struct SqList L);
Status GetElem(struct SqList L, int i, ElemType *e);
int LocateElem(struct SqList L, ElemType e, Status (*compare)(ElemType, ElemType));
Status PriorElem(struct SqList L, ElemType cur_e, ElemType *pre_e);
Status NextElem(struct SqList L, ElemType cur_e, ElemType *next_e);
Status ListInsert(struct SqList *L, int i, ElemType e);
Status ListDelete(struct SqList *L, int i, ElemType *e);
void ListTraverse(struct SqList L, void (*vi)(ElemType *));

Status equal(ElemType c1, ElemType c2);
int comp(ElemType a, ElemType b);
void print(ElemType c);
void print2(ElemType c);
void print1(ElemType *c);

#endif /* __SEQUENCE_H__ */

/****************** end of file ********************/
